
//模型数据
var model;
//风力数据
var windData;
//降水数据
var waterData;
//可见度数据
var visibilityData;
// 温度数据
var TemperatureData;
//大风数据
var galeData;
//雷电数据
var thunderData;
//雾数据
var fogData;
//雨加雪数据
var rainData;

///加载数据模型
function reloadTypeModel(value) {
	value = parseInt(value)
	if (value == 1) {
		windData = [['1','港口1级风力描述'],['2','港口2级风力描述'],['3','港口3级风力描述'],['4','港口4级风力描述'],['5','港口5级风力描述'],]
		waterData = [['40','港口40mm降水描述'],['80','港口80mm降水描述'],['120','港口120mm降水描述'],['160','港口160mm降水描述'],['200','港口200mm降水描述'],]
		visibilityData = [['5','港口5m能见度描述'],['10','港口10m能见度描述'],['15','港口15m能见度描述'],['20','港口20m能见度描述'],['25','港口25m能见度描述'],]
		TemperatureData = [['10','港口10℃描述'],['20','港口20℃描述描述'],['30','港口30级风力描述'],['40','港口40℃描述描述'],['50','港口50℃描述描述'],]
		galeData = [['1','港口1级大风描述'],['2','港口2级大风描述'],['3','港口3级大风描述'],['4','港口4级大风描述'],['5','港口5级大风描述'],]
		thunderData = [['1','港口1级雷电描述'],['2','港口2级雷电描述'],['3','港口3级雷电描述'],['4','港口4级雷电描述'],['5','港口5级雷电描述'],]
		fogData = [['1','港口1级雾描述'],['2','港口2级雾描述'],['3','港口3级雾描述'],['4','港口4级雾描述'],['5','港口5级雾描述'],]
		rainData = [['1','港口1级雨加雪描述'],['2','港口2级雨加雪描述'],['3','港口3级雨加雪描述'],['4','港口4级雨加雪描述'],['5','港口5级雨加雪描述'],]
	} else if (value == 2) {
		windData = [['1','电力1级风力描述'],['2','电力2级风力描述'],['3','电力3级风力描述'],['4','电力4级风力描述'],['5','电力5级风力描述'],]
		waterData = [['40','电力40mm降水描述'],['80','电力80mm降水描述'],['120','电力120mm降水描述'],['160','电力160mm降水描述'],['200','电力200mm降水描述'],]
		visibilityData = [['5','电力5m能见度描述'],['10','电力10m能见度描述'],['15','电力15m能见度描述'],['20','电力20m能见度描述'],['25','电力25m能见度描述'],]
		TemperatureData = [['10','电力10℃描述'],['20','电力20℃描述描述'],['30','电力30级风力描述'],['40','电力40℃描述描述'],['50','电力50℃描述描述'],]
		galeData = [['1','电力1级大风描述'],['2','电力2级大风描述'],['3','电力3级大风描述'],['4','电力4级大风描述'],['5','电力5级大风描述'],]
		thunderData = [['1','电力1级雷电描述'],['2','电力2级雷电描述'],['3','电力3级雷电描述'],['4','电力4级雷电描述'],['5','电力5级雷电描述'],]
		fogData = [['1','电力1级雾描述'],['2','电力2级雾描述'],['3','电力3级雾描述'],['4','电力4级雾描述'],['5','电力5级雾描述'],]
		rainData = [['1','电力1级雨加雪描述'],['2','电力2级雨加雪描述'],['3','电力3级雨加雪描述'],['4','电力4级雨加雪描述'],['5','电力5级雨加雪描述'],]
	} else if (value == 3) {
		windData = [['1','鞍钢1级风力描述'],['2','鞍钢2级风力描述'],['3','鞍钢3级风力描述'],['4','鞍钢4级风力描述'],['5','鞍钢5级风力描述'],]
		waterData = [['40','鞍钢40mm降水描述'],['80','鞍钢80mm降水描述'],['120','鞍钢120mm降水描述'],['160','鞍钢160mm降水描述'],['200','鞍钢200mm降水描述'],]
		visibilityData = [['5','鞍钢5m能见度描述'],['10','鞍钢10m能见度描述'],['15','鞍钢15m能见度描述'],['20','鞍钢20m能见度描述'],['25','鞍钢25m能见度描述'],]
		TemperatureData = [['10','鞍钢10℃描述'],['20','鞍钢20℃描述描述'],['30','鞍钢30级风力描述'],['40','鞍钢40℃描述描述'],['50','鞍钢50℃描述描述'],]
		galeData = [['1','鞍钢1级大风描述'],['2','鞍钢2级大风描述'],['3','鞍钢3级大风描述'],['4','鞍钢4级大风描述'],['5','鞍钢5级大风描述'],]
		thunderData = [['1','鞍钢1级雷电描述'],['2','鞍钢2级雷电描述'],['3','鞍钢3级雷电描述'],['4','鞍钢4级雷电描述'],['5','鞍钢5级雷电描述'],]
		fogData = [['1','鞍钢1级雾描述'],['2','鞍钢2级雾描述'],['3','鞍钢3级雾描述'],['4','鞍钢4级雾描述'],['5','鞍钢5级雾描述'],]
		rainData = [['1','鞍钢1级雨加雪描述'],['2','鞍钢2级雨加雪描述'],['3','鞍钢3级雨加雪描述'],['4','鞍钢4级雨加雪描述'],['5','鞍钢5级雨加雪描述'],]
	} else if (value == 4) {
		windData = [['1','供暖1级风力描述'],['2','供暖2级风力描述'],['3','供暖3级风力描述'],['4','供暖4级风力描述'],['5','供暖5级风力描述'],]
		waterData = [['40','供暖40mm降水描述'],['80','供暖80mm降水描述'],['120','供暖120mm降水描述'],['160','供暖160mm降水描述'],['200','供暖200mm降水描述'],]
		visibilityData = [['5','供暖5m能见度描述'],['10','供暖10m能见度描述'],['15','供暖15m能见度描述'],['20','供暖20m能见度描述'],['25','供暖25m能见度描述'],]
		TemperatureData = [['10','供暖10℃描述'],['20','供暖20℃描述描述'],['30','供暖30级风力描述'],['40','供暖40℃描述描述'],['50','供暖50℃描述描述'],]
		galeData = [['1','供暖1级大风描述'],['2','供暖2级大风描述'],['3','供暖3级大风描述'],['4','供暖4级大风描述'],['5','供暖5级大风描述'],]
		thunderData = [['1','供暖1级雷电描述'],['2','供暖2级雷电描述'],['3','供暖3级雷电描述'],['4','供暖4级雷电描述'],['5','供暖5级雷电描述'],]
		fogData = [['1','供暖1级雾描述'],['2','供暖2级雾描述'],['3','供暖3级雾描述'],['4','供暖4级雾描述'],['5','供暖5级雾描述'],]
		rainData = [['1','供暖1级雨加雪描述'],['2','供暖2级雨加雪描述'],['3','供暖3级雨加雪描述'],['4','供暖4级雨加雪描述'],['5','供暖5级雨加雪描述'],]
	}
 
}

///创建数据模型
function creataeItemModel(num,text) {
	 var model=new Obejct();
	 
	 model.num = num;
	 model.text = text;
	 
	 return model;
}

//生成建议按钮点击
function sureClick() {
	
	//刷新数据
	reloadTypeModel($('input[name="optradio"]:checked').val())
	
	var modelArr = [
		['风力', 'minWind', 'maxWind',windData],
		['降水', 'minWater', 'maxWater',waterData],
		['能见度', 'visibility', 'visibility',visibilityData],
		['温度', 'minTemperature', 'maxTemperature',TemperatureData],
		['大风', 'gale', 'gale', galeData],
		['雷电', 'thunder', 'thunder', thunderData],
		['雾', 'fog', 'fog',fogData],
		['雨加雪', 'rain', 'rain',rainData],
	]

	//输出编号
	var indexNum = 1;
	//输出建议
	var text = ''
	for (var i = 0; i < modelArr.length; i++) {
		var arr = modelArr[i];
		var str = getStr(arr[1], arr[2], arr[0],arr[3])

		//拼接数据
		if (str.length > 0) {
			text = text + indexNum.toString() + '. ' + str + '\n'
			indexNum++
		}

	}

	//其他建议
	var otherTextArr = [
		
	]

	//输出建议
	for (var i = 0; i < otherTextArr.length; i++) {
		var arr = otherTextArr[i]
		if (parseInt(arr[1]) > 0) {
			text = text + indexNum.toString() + '. ' + arr[0] + arr[2] + '\n'
			indexNum++
		}
	}

	$('#recommendView').text(text)

}

//获取建议
function getStr(name1, name2, text,dataArray) {

	//最小值
	var minStr = $('#' + name1).val()
	if (minStr.length == 0) {
		minStr = '0'
	}

	//最大值
	var maxStr = $('#' + name2).val()
	if (maxStr.length == 0) {
		maxStr = '0'
	}

	var max = Math.max(parseInt(minStr), parseInt(maxStr))

	if (max == 0) {
		return ''
	}
	//获取建议字符
	for (var i = dataArray.length - 1; i > -1; i--) {
		var modelArr = dataArray[i]
		
		//数值
		var num = modelArr[0]
		
		//大于等于建议数值
		if (max >= num) {
			return text + ':' + modelArr[1]
		}
	}
	return text + ':超出建议范围'
}

//下载建议
function downClick() {
	//修改视图
	var text = $("#recommendView").text()
	text = text.replace(/\n/g,'<br>')
	$("#downContentStr").html(text)
	
	//下载文件
	$("#downContent").wordExport('建议');
}
